<?php

use yii\helpers\Html;
use yii\grid\GridView;
use yii\widgets\Pjax;

$this->title = Yii::t('app.cruise', 'Templates');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="template-index">
    <h2 class="page-header"><?= Html::encode($this->title) ?>
        <p class="pull-right">
            <?= Html::a(Yii::t('app.cruise', 'Create Template'), ['create', 'cruise_id'=>$cruise_id], ['class' => 'btn btn-success']) ?>
        </p>
    </h2>

<?php Pjax::begin(); ?>    
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'columns' => [
            //['class' => 'yii\grid\SerialColumn'],
            //'id',
            'cruise.name',
            'name',
            [
                'attribute' => 'from_city',
                'filter' =>  Yii::$app->params['city'],
                'value' => function ($model) {
                        return empty($model->from_city) ? '(未设置)' : Yii::$app->params['city'][$model->from_city];
                    },
            ],
            [
                'attribute' => 'to_city',
                'filter' =>  Yii::$app->params['city'],
                'value' => function ($model) {
                        return empty($model->to_city) ? '(未设置)' : Yii::$app->params['city'][$model->to_city];
                    },
            ],
            // 'line',
            // 'trip:ntext',
            [
                'attribute' => 'status',
                'filter' =>  Yii::$app->params['status'],
                'value' => function ($model) {
                        return Yii::$app->params['status'][$model->status];
                    },
            ],
            'created_at:relativeTime',
            ['class' => 'yii\grid\ActionColumn'],
        ],
    ]); ?>
<?php Pjax::end(); ?></div>
